package Level01.Two;

/**
 * 卖票
 */
public class Section implements Runnable {
    //定义票数
    private static int ticket = 1000;

    @Override
    public void run() {
        while (true) {
            synchronized (this) {
                if (ticket <= 0) {
                    break;
                }
                    System.out.println(Thread.currentThread().getName() + "卖出了第" + ticket  + "张票");
                    ticket--;
                }
            }
        }
    }

